package com.zjn.serviceb.config;


import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

/**
 * @author zaker
 * @program: signit-test
 * @date 2021-03-29 12:37
 */
@Configuration
public class DataSourceConfig {
    @Bean(name = "ADataSource")
    @Qualifier("ADataSource")
    @ConfigurationProperties(prefix="spring.datasource.a")
    public DataSource ADataSource() {
        return DataSourceBuilder.create().build();
    }

    @Bean(name = "BDataSource")
    @Qualifier("BDataSource")
    @ConfigurationProperties(prefix="spring.datasource.b")
    @Primary
    public DataSource BDataSource() {
        return DataSourceBuilder.create().build();
    }

    @Bean(name = "CDataSource")
    @Qualifier("CDataSource")
    @ConfigurationProperties(prefix="spring.datasource.c")
    public DataSource CDataSource() {
        return DataSourceBuilder.create().build();
    }
}
